// Copyright (C) Microsoft Corporation. All rights reserved.

using System;
using Microsoft.WowAddonStudio.Lua.RuntimeService.WowBench;

namespace Microsoft.WowAddonStudio.Lua.RuntimeService.ShellHost
{
	public enum CtrlEvent
	{
		CTRL_C_EVENT = 0,
		CTRL_BREAK_EVENT
	}

	public enum ShellHostState
	{
		Closed = 0,
		Running
	}

	/// <summary>
	/// Any shell to be hosted under VSCmdShell must implement this interface in order for ShellTextBox to interact
	/// with the shell.
	/// </summary>
	public interface IShellHost : IDisposable
	{
		/// <summary>
		/// Fires when the <see cref="System.Diagnostics.Process"/> exited.
		/// </summary>
		event EventHandler<ProcessExitedEventArgs> OnProcessExited;

		/// <summary>
		/// A descriptive name for the <see cref="IShellHost"/>.
		/// </summary>
		string ShellName { get; }

		/// <summary>
		/// The current state of <see cref="IShellHost"/>.
		/// </summary>
		ShellHostState ShellState { get; }

		/// <summary>
		/// Executes a command on the <see cref="IShellHost"/>.
		/// </summary>
		/// <param name="command">Command to execute.</param>
		void ExecuteCommand(string command);

		/// <summary>
		/// Allows shell to expand environment variables before command is processed.
		/// This will be used when executing internal Visual Studio commands.
		/// </summary>
		/// <param name="input">The input <see cref="String"/>.</param>
		/// <returns></returns>
		string ExpandEnvironmentVariables(string input);

		/// <summary>
		/// This method is called when ShellTextBox creates the host instance for the first time. 
		/// </summary>
		/// <param name="startingDirectory">Preferred directory to start in.</param>
		/// <param name="outputWriter">The <see cref="IOutputWriter"/> parameter.</param>
		/// <remarks>This method will only be called once at the beginning.</remarks>
		bool LaunchShellProcess(IOutputWriter outputWriter, string startingDirectory);

		/// <summary>
		/// This method is called when ShellTextBox creates the host instance for the first time. 
		/// </summary>
		/// <param name="startingDirectory">Preferred directory to start in.</param>
		/// <param name="outputWriter">The <see cref="IOutputWriter"/> parameter.</param>
		/// <param name="executableName">The name of executable to load.</param>
		/// <remarks>This method will only be called once at the beginning.</remarks>
		bool LaunchShellProcess(IOutputWriter outputWriter, string startingDirectory, string executableName);

		/// <summary>
		/// This method is called when ShellTextBox creates the host instance for the first time. 
		/// </summary>
		/// <param name="startingDirectory">Preferred directory to start in.</param>
		/// <param name="outputWriter">The <see cref="IOutputWriter"/> parameter.</param>
		/// <param name="executableName">The name of executable to load.</param>
		/// <param name="argument">The argument for executable.</param>
		/// <remarks>This method will only be called once at the beginning.</remarks>
		bool LaunchShellProcess(IOutputWriter outputWriter, string startingDirectory, string executableName, string argument);

		/// <summary>
		/// Terminates the child <see cref="System.Diagnostics.Process"/> in console.
		/// </summary>
		/// <returns>True if success, otherwise false.</returns>
		bool TerminateChildProcess();
	}
}